package store.lunangangster.engine.impl.el;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.el.FunctionMapper;

public class DefaultFunctionMapper extends FunctionMapper {

  protected Map<String, Method> methodCache = null;

  @Override
  public Method resolveFunction(String prefix, String localName) {
    return methodCache == null ? null : methodCache.get(prefix + "." + localName);
  }

  public void setFunction(String prefix, String localName, Method method) {
    if (methodCache == null) {
      methodCache = new HashMap<>();
    }
    methodCache.put(prefix + "." + localName, method);
  }
}
